<template>
  <!--  -->
  <div>
    <avue-crud
      id="crud"
      :option="option"
      :data="BOMdata"
      :table-loading="BOMloading"
      ref="crud"
    >
      <template slot-scope="{row}" slot="menu">
        <el-tooltip content="删除" style="height:auto" effect="dark" class="rightbtn" placement="bottom">
          <div class="top-bar__item">
            <el-button :disabled="mainStatus==2" type="text" size="small" icon="el-icon-delete" @click.stop="rowDel(row)"></el-button>
          </div>
        </el-tooltip>
      </template>
    </avue-crud>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import { init } from '@/mixins/init'
import * as product from '@/api/project/productData/product'
export default {
  mixins: [init],
  props: ['BOMdata', 'BOMloading', 'mainStatus'],
  data() {
    return {
      option: {
        tip: false,
        addBtn: false,
        editBtn: false,
        delBtn: false,
        border:true,
        index: true,
        menuWidth: 60,
        searchLabelWidth: 120,
        viewBtn:false,
        column: [
          {
            label: '物料编码',
            prop: 'materialNo',
            minWidth: 130,
            overHidden: true,
          },

          {
            label: '物料名称',
            prop: 'materialName',
            minWidth: 130,
            overHidden: true,
          },
          {
            label: '工位',
            prop: 'stationNo',
            minWidth: 130,
            overHidden: true,
          },
          {
            label: '单件用量',
            prop: 'quota',
            minWidth: 130,
            overHidden: true,
          },
          {
            label: '扣料配置',
            prop: 'buckleType',
            type:'select',
            dicData:[
              {
                label:'工位',value:1
              },
              {
                label:'站位',value:2
              },
            ],
            minWidth: 130,
            overHidden: true,
          },
          {
            label: '错误值配置',
            prop: 'errorValue',
            minWidth: 130,
            overHidden: true,
          },
        ]
      }
    }
  },

  computed: {
    ...mapGetters(['permission', 'userId']), //权限映射
  },
  created (){},
  methods: {
    rowDel (row) {
      this.$confirm('确认删除数据吗？', '提示', {
        confirmButtonText: '确认',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        product.bomRemove(row.id).then(res => {
          this.$message.success(res.data.msg)
          this.$emit('getBom')
        })
      }).catch(() => {})
    },
    // onLoad(page,params={}){
    //   this.loading = true
    //   product.productBomList(this.currentMaterialNo).then((res) => {
    //     const data = res.data.data;
    //     this.BOMdata = data;
    //   })
    // },
  },
  destroyed(){}
};
</script>

<style scoped lang="scss">

</style>
